﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class LineTechnologyRouteConfig : POBaseConfig<LineTechnologyRoutePO>
    {
        public override void InitializeData(EntityTypeBuilder<LineTechnologyRoutePO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<LineTechnologyRoutePO> builder, ref int index)
        {
            builder.HasComment("产线自动组盘工艺路径表");
            builder.Property(entity => entity.LineCode).ConfigColumn("LINE_CODE", "产线编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StationCode).ConfigColumn("STATION_CODE", "站台编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyRouteCode).ConfigColumn("TECHNOLOGY_ROUTE_CODE", "工艺路径编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<LineTechnologyRoutePO> builder)
        {
            builder.HasIndex(entity => new { entity.StationCode, entity.LineCode, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1").IsUnique();
        }
    }
}
